package com.database.daos.imp;

import java.util.List;

import com.database.daos.IContributionDao;
import com.database.objects.*;

public class ContributionDao extends GenericDao<Contribution> implements IContributionDao {

	private static final long serialVersionUID = 3499789291582650859L;

	@Override
	@SuppressWarnings("unchecked")
	public Contribution getByDeveloperAndDateAndTypeAndStatus(Developer developer, String date, Type type, Status status) {
		String[] params = new String[] { "developer", "date", "type", "status" };
		Object[] values = new Object[] { developer, date, type, status };
		List<Contribution> contributions = findByNamedQueryAndNamedParam("Contribution.getByDeveloperAndDateAndTypeAndStatus", params, values);
		return !contributions.isEmpty() ? contributions.get(0) : null;
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Contribution> findByDeveloperAndTypeAndDate(Developer developer, Type type, Status status, String start, String finish) {
		String[] params = new String[] { "developer", "type", "status", "start", "finish" };
		Object[] values = new Object[] { developer, type, status, start, finish };
		return findByNamedQueryAndNamedParam("Contribution.findByDeveloperAndTypeAndDate", params, values);
	}

}